import router from './router'
import { cache } from '@utils'

router.beforeEach((to, from, next) => {
  const userInfo = cache.get('userInfo')
  console.log(to.path)
  if (userInfo && to.path !== '/login') {
    next()
  } else if (userInfo && to.path === '/login') {
    next('/')
  } else if (!userInfo && to.path !== '/login'){
    next('/login')
  } else {
    next()
  }
})
